 package uk.co.mmscomputing.device.twain;
 
 import java.awt.Image;
 import java.awt.image.BufferedImage;
 import java.awt.image.DataBufferByte;
 import java.awt.image.IndexColorModel;
 import java.awt.image.Raster;
 import java.awt.image.WritableRaster;
 import uk.co.mmscomputing.imageio.bmp.BMPMetadata;
 
 public class TwainBufferedImage extends BufferedImage
 {
   private static String[] propertyNames = { "iiometadata" };
   private BMPMetadata md = new BMPMetadata();
 
   public TwainBufferedImage(int paramInt1, int paramInt2, int paramInt3) {
     super(paramInt1, paramInt2, paramInt3);
 
     int i = 24;
 
     this.md.setWidth(paramInt1);
     this.md.setHeight(paramInt2);
     this.md.setBitsPerPixel(i);
     this.md.setCompression(0);
     this.md.setImageSize((paramInt1 * i + 31 >> 5 << 2) * paramInt2);
     this.md.setXPixelsPerMeter(2953);
     this.md.setYPixelsPerMeter(2953);
   }
 
   public TwainBufferedImage(int paramInt1, int paramInt2, int paramInt3, IndexColorModel paramIndexColorModel) {
     super(paramInt1, paramInt2, paramInt3, paramIndexColorModel);
 
     this.md.setWidth(paramInt1);
     this.md.setHeight(paramInt2);
 
     int i = 8;
     switch (paramIndexColorModel.getMapSize()) { case 2:
       i = 1; break;
     case 16:
       i = 4;
     }
 
     this.md.setBitsPerPixel(i);
     this.md.setCompression(0);
     this.md.setXPixelsPerMeter(2953);
     this.md.setYPixelsPerMeter(2953);
     this.md.setIndexColorModel(paramIndexColorModel);
     this.md.setImageSize((paramInt1 * i + 31 >> 5 << 2) * paramInt2);
   }
 
   public byte[] getBuffer() {
     WritableRaster localWritableRaster = getRaster();
     DataBufferByte localDataBufferByte = (DataBufferByte)localWritableRaster.getDataBuffer();
     return localDataBufferByte.getData();
   }
 
   public void setXPixelsPerMeter(int paramInt) {
     this.md.setXPixelsPerMeter(paramInt);
   }
 
   public void setYPixelsPerMeter(int paramInt) {
     this.md.setYPixelsPerMeter(paramInt);
   }
 
   public void setPixelsPerMeter(int paramInt1, int paramInt2) {
     setXPixelsPerMeter(paramInt1);
     setYPixelsPerMeter(paramInt2);
   }
 
   public Object getProperty(String paramString) {
     if (paramString.equals("iiometadata")) return this.md;
     if (paramString.equals("resolution")) {
       return "" + this.md.getXDotsPerInch();
     }
     return Image.UndefinedProperty;
   }
 
   public String[] getPropertyNames() {
     return propertyNames;
   }
 }

